package features.advance.leetcode.interview;

/**
 *
 *  类加载机制
 *
 * @author LIN
 * @date 2021-05-12
 */
public class ClassLoaderMain extends A {
    static {
        System.out.println("B");
    }
    private static final ClassLoader classLoader = new ClassLoader(){};

    public static void main(String[] args) {

        classLoader.load();
        classLoader.verify();
        classLoader.prepare();
        classLoader.analysis();
        classLoader.init();
        classLoader.use();
        classLoader.unload();

        java.lang.ClassLoader systemClassLoader = java.lang.ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);
        java.lang.ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);
        java.lang.ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);
//        java.lang.ClassLoader parent2 = parent1.getParent();

        System.out.println("short类型占用字节数："+Short.SIZE / 8);
        System.out.println("int类型占用字节数："+Integer.SIZE / 8);
        System.out.println("char类型占用字节数："+Character.SIZE / 8);

        String a = "intern";
        String b = new String("intern");
        String c = "intern";

        String intern = c.intern();
        System.out.println(intern == c);
        System.out.println(a == b);
        System.out.println(a == c);




    }

    interface ClassLoader {
        /**
         * 加载
         */
        default void load(){};

        /**
         * 验证
         */
        default void verify(){};

        /**
         * 准备
         */
        default void prepare(){};

        /**
         * 解析
         */
        default void analysis(){};

        /**
         * 初始化
         */
        default void init(){};

        /**
         * 使用
         */
        default void use(){};

        /**
         * 卸载
         */
        default void unload(){};
    }
}